local duandizi = fk.CreateSkill{
  name = "lzsj__duandizi",
  tags = { "Phase" },
}

Fk:loadTranslationTable{
  ["lzsj__duandizi"] = "断敌辎",
  ["#lzsj__duandizi"] = "你可移动其他角色场上一张黑色装备牌至你",
  [":lzsj__duandizi"] = "阶段技，你可选择一张场上有黑色装备牌的其他角色，其需打出一张【闪】，否则你将其一张黑色装备牌移动至你的装备区。",
  ["#duandizi-ask"] = "请打出一张【闪】，否则%src移动你一张黑色装备牌至其装备区",

  ["$lzsj__duandizi1"] = "炸铁路！烧粮仓！",
  ["$lzsj__duandizi2"] = "一包炸药，换三车军粮！",
}

duandizi:addEffect("active", {
  anim_type = "control",
  prompt = "#lzsj__duandizi",
  max_phase_use_time = 1,
  card_num = 0,
  target_num = 1,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and table.find(to_select:getCardIds("e"), function (id)
      return Fk:getCardById(id).color == Card.Black
    end) and to_select:canMoveCardsInBoardTo(player, "e", table.filter(to_select:getCardIds("e"), function (id)
      return Fk:getCardById(id).color ~= Card.Black end))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local params = { ---@type AskToUseCardParams
      skill_name = "jink",
      pattern = "jink",
      prompt = "#duandizi-ask:" .. player.id,
      cancelable = true,
    }
    local respond = room:askToResponse(target, params)
    if respond then
      room:responseCard(respond)
    else
      local cards = table.filter(target:getCardIds("e"), function (id)
        return Fk:getCardById(id).color ~= Card.Black
      end)
      room:askToMoveCardInBoard(player, {
        target_one = target,
        target_two = player,
        skill_name = duandizi.name,
        flag = "e",
        move_from = target,
        exclude_ids = cards,
      })
    end
  end,
})

return duandizi